<h1>Happy New Year</h1>
<br/>
<style>
#tree{
	min-width:750px;
	height:350px;
	background-image:url(holidays/newyear/grass.png);
	background-color:#00b4ff;
	background-repeat:repeat-x;
	float:left;
}
</style>
	<script>
	function updateLocation(type, x, y){
		x = x + 370;
		<?php if(checkLastSBuilding()){ ?>
		y = y - 138
		<?php } ?>
		jQuery("#"+type).draggable("destroy");
		document.getElementById(type).style.cursor = 'default';
		if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp=new XMLHttpRequest();
		}else{// code for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function(){
			if (xmlhttp.readyState==4 && xmlhttp.status==200){
				document.getElementById('statusText').innerHTML = 'Care to Try Again?<br/><br/><input type="button" value=" Try Again " onclick="location.reload(true)" />';
		    }
	    }
	    xmlhttp.open("GET","http://192.168.120.9/techcenter/holidays/UpdateNewYear.php?type="+type+"&x="+x+"&y="+y,true);
	    xmlhttp.send();
	}
	</script>
    <?php
	$sql = "SELECT * FROM `tbSignins` WHERE `sDateTime` LIKE :now AND `sTech` = :tech";
	$q = db::Query($sql, array(':now'=>"%".date('F j, Y')."%", ':tech'=>$USER['sFname']." ".$USER['sLname']));
	$signedin = false;
	while($row = $q->fetch()){
		$signedin = true;
	}
	$luck = rand(1, 100);
	$lucky = rand(1, 100);
	
	$sql = "SELECT * FROM `tbHolidayLog` WHERE `sUser` = :uname";
	$q = db::Query($sql, array(':uname'=>$USER['sUname']));
	$row_free = $q->fetch();
	if($row_free['iCount'] != 0 and $row_free['iCount'] != ''){
		$luck = $lucky;
	}
	?>
    <table width="100%">
    	<tr>
        	<td width="750">
			So, here is a new game! You have a 1 in 100th chance to recieve a firework cannon to place on the grass.<br/>
			<br/>
			Although, there are some rules:<br/>
			1) <strong>You</strong> must sign-in at least one legitimate customer each day before the game becomes active.<br/>
            - or -<br/>
            1) <strong>You</strong> must submit at least one legitaimate class-room down each day before the game becomes active.<br/>
			2) If an S-Building report has not been done in 6 hours the game is disabled.<br/>
			3) If you enter a classroom down you automatically recieve a firework cannon.<br/><br/>
            </td>
            <td>
            </td>
		</tr>
        <tr>
	        <td>
			<div id="tree">
            <?php
			$sql = "SELECT * FROM `tbNewYear`";
			$q = db::Query($sql);
			while($row = $q->fetch()){
				$ran = rand(0, 9999999999);
				$sql = "SELECT * FROM SPRIDEN, GOBTPAC WHERE SPRIDEN_PIDM = GOBTPAC_PIDM AND GOBTPAC_EXTERNAL_USER = :uname AND SPRIDEN_CHANGE_IND is null";
				$q2 = Oracle::Query($sql, array(':uname'=>$row['sUser']));
				$row2 = $q2->fetch();
				//$row['sY'] = $row['sY'] + 26;
				$row['sY'] = 561;
			?>
            <div id="<?php echo $ran ?>" title="Added By <?php echo $row2['SPRIDEN_FIRST_NAME']." ".$row2['SPRIDEN_LAST_NAME'] ?>" style="background-image:url(holidays/newyear/firework.png); width:27px; height:89px; position:absolute; left:<?php echo ($row['sX']) ?>px; top:<?php echo $row['sY'] ?>px"></div></div>
            <script>
			jQuery('#<?php echo $ran ?>').tooltip({
				delay: 0,
				showURL: false
			});
			</script>
            <?php } ?>
           	</td>
            <td align="center" style="font-size:18px; font-weight:bold">
            <?php if(checkLastSBuilding() and ($row_free['iCount'] == 0 or $row_free['iCount'] == '')){ ?>
            An S-Building Report<br/>
            Must Be Done First!
            <?php }elseif(!$signedin and ($row_free['iCount'] == 0 or $row_free['iCount'] == '')){ ?>
            You Must Sign In<br/>
            a Customer First!<br/><br/>
            -or-<br/><br/>
            Enter A Classroom<br/>
            Down First!
            <?php }else{ ?>
            <?php if($lucky != $luck){ ?>
            You Are Not A Winner!<br/>
            <br/>
    	    <input type="button" value=" Try Again " onclick="location.reload(true)" /><br/>
            <?php }else{ ?>
            <span id="statusText">
            <?php if($row_free['iCount'] != 0 and $row_free['iCount'] != ''){ ?>
            You Entered <?php echo $row_free['iCount'] ?><br/>
            Classroom Down(s)!<br/>
            <br/>
            Here is a freebie!<br/>
            <?php }else{ ?>
            Congratulations!<br/>
            You Won!<br/>
            <?php } ?>
            <br/>
            </span>
            <script>
			jQuery(function() {
				jQuery("#firework").draggable({
					stop: function(){
						updateLocation(jQuery(this).attr('id'), jQuery(this).position().left, jQuery(this).position().top);
					}
				});
			});
			</script>
            <div id="firework" style="background-image:url(holidays/newyear/firework.png); height:89px; width:27px"></div>
            <?php } ?>
            <?php } ?>
            </td>
		</tr>
	</table>